import { User } from '../login/model/user';
import { Component, OnInit } from '@angular/core';
import {NzMessageService} from 'ng-zorro-antd';
import {Router} from '@angular/router';

@Component({
  selector: 'home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
  public currentUser:User;
  constructor(
    private nzMsg:NzMessageService,
    public router:Router,
  ) { }

  ngOnInit() {
    this.currentUser=JSON.parse(window.localStorage.getItem("currentUser"));
    if(!this.currentUser){
      console.log("用户未登录，重定向到登录页");
      this.router.navigateByUrl("/login");
    }
  }

  showMsg():void{
    this.nzMsg.info("本区域为内容展示区,本提示5秒后消失",{nzDuration:500000});
  }
}
